from . import system_blueprint
from ..utils.exception import APIException
from ..utils.score_calc import *
from ..utils.response_util import *

from flask import request


@system_blueprint.route("/", methods=["GET", "POST"])
def main():
    return "System"


@system_blueprint.errorhandler(APIException)
def error(e):
    return APIException.to_dict(e)


@system_blueprint.route("/restart", methods=["GET", "POST"])
def restart():
    pass


@system_blueprint.route("/test/score", methods=["GET"])
def score_calc_test():
    data = request.args
    user_id = data.get("userId")
    homework_id = data.get("homeworkId")

    score = score_submit_homework(homework_id, user_id)

    return response(111, "Score Update Success", {"score": score})
